package com.example.duanlei417.mypro2.view.utils;

import android.graphics.Rect;
import android.util.Log;
import android.view.View;

public class VisibilityCheckUtil {

    public static float check(View childView, View parentView) {

        Rect parentRect = new Rect();

        parentView.getHitRect(parentRect);
        Log.e("testdl", "hitRect----parentRect-------" + parentRect);

        boolean isIntersect = childView.getLocalVisibleRect(parentRect);

        Log.e("testdl", "LocalVisibleRect----parentRect-------" + parentRect);

        if (!isIntersect) {
            return 0;
        }

        float ratio = (float)parentRect.bottom/(float)childView.getHeight();

        Log.e("testdl", "childView.getHeight()-------" + childView.getHeight());
        Log.e("testdl", "ratio-------" + ratio);

        return ratio;
    }
}
